/*************************************************
Author: byron
Date: 01/28/2013
Description:
Notes: 
*************************************************/

#ifndef __CTreasureCfg_h__
#define __CTreasureCfg_h__

#include "commclass.h"

//秘宝配置项
class CTreasureCfgData
{
public:
    CTreasureCfgData() 
    {
        Clear();
    }

    void Clear()
    {
        _iResID = 0;
        _iOrder = 0;
        
        _aiStatusID.m_iUsedCount = _aiStatusID.GetCount();
        for (int i = 0; i < _aiStatusID.Size(); ++i)
        {
            _aiStatusID[i] = 0;
        }
    }

    virtual ~CTreasureCfgData() 
    {
    }

    bool IsValidID() const
    {
        return (_iResID > 0 && _iResID <= MAX_TREASURE_CFG_COUNT);
    }

    int GetResID() const {return _iResID;}
    int GetOrder() const {return _iOrder;}
    int GetStatusIDSize() const {return _aiStatusID.Size();}
    short GetStatusID(int iIndex)
    {
        if (iIndex >= 0 && iIndex < _aiStatusID.Size())
        {
            return _aiStatusID[iIndex];
        }

        return 0;
    }

    void SetResID (int iResID) {_iResID = iResID;}
    void SetOrder (int iOrder) {_iOrder = iOrder;}
    int SetStatusID(int iIndex, int iStatusID)
    {
        if (iIndex < 0 || iIndex >= _aiStatusID.Size())
        {
            return -1;
        }

        _aiStatusID[iIndex] = iStatusID;

        return 0;
    }

private:
    int               _iResID;           //资源ID
    int               _iOrder;          //排序值
    CTLib::CTArray<int, MAX_TREASURE_UP_LEVEL> _aiStatusID;      //能力ID
};

//秘宝升级配置项
class CTreasureUpCfgData
{
public:
    CTreasureUpCfgData() 
    {
        Clear();
    }

    void Clear()
    {
        _shLevel = -1;//必须负值
        _iSpirit = 0;
        _iSilver = 0;
        _iAttrType = 0;
        _iAttrData = 0;
    }

    virtual ~CTreasureUpCfgData() 
    {
    }

    bool IsValidLevel() const
    {
        //策划要求 秘宝初始等级为0级
        return (_shLevel >= 0 && _shLevel < MAX_TREASURE_UP_LEVEL);
    }
    
    bool IsValidValue() const
    {
        return (_iSpirit > 0 && _iSilver > 0);
    }

    short GetLevel() const {return _shLevel;}
    int GetSpirit() const {return _iSpirit;}
    int GetSilver() const {return _iSilver;}
    int GetAttrType() const {return _iAttrType;}
    int GetAttrData() const {return _iAttrData;}

    void SetLevel (short shLevel) {_shLevel = shLevel;}
    void SetSpirit (int iSpirit) {_iSpirit = iSpirit;}
    void SetSilver (int iSilver) {_iSilver = iSilver;}
    void SetAttrType (int iAttrType) {_iAttrType = iAttrType;}
    void SetAttrData (int iAttrData) {_iAttrData = iAttrData;}

private:
    short       _shLevel;   //等级
    int         _iSpirit;   //灵力
    int         _iSilver;   //银币
    int         _iAttrType;
    int         _iAttrData;
};

//秘宝配置
class CTreasureCfg
{
public:
    CTreasureCfg() 
    {
    }

    virtual ~CTreasureCfg() 
    {
    }

    void InitConfig();

    int AddConfig(CTreasureCfgData& stCfgData);

    int FindConfig(int iResID);

    CTreasureCfgData& GetConfig(int iIndex) {return _astTreasureCfg[iIndex];}

    int AddUpConfig(CTreasureUpCfgData& stCfgData);

    int FindUpConfig(short shLevel);

    CTreasureUpCfgData& GetUpConfig(int iIndex)
    {
        return _astTreasureUpCfg[iIndex];
    }

private:
    CTLib::CTArray<CTreasureCfgData, MAX_TREASURE_CFG_COUNT> _astTreasureCfg;

    CTLib::CTArray<CTreasureUpCfgData,MAX_TREASURE_UP_LEVEL> _astTreasureUpCfg;
};

typedef CTLib::CTArray<int, MAX_TREASURE_ACT_COUNT> T_TREASURE_ACT_DATA;

#endif // __CTreasureCfg_h__


